import { Component, Input } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { FormControlItem } from '../getControls';
import { ControlFieldSchemaSection } from '../json-schema';

@Component({
  selector: 'app-form-field',
  templateUrl: './form-field.component.html',
  styleUrl: './form-field.component.scss'
})
export class FormFieldComponent {
  @Input() group!: FormGroup;
  @Input() control!: FormControlItem;
  @Input() groupName?: string;
  @Input() schema!: ControlFieldSchemaSection;

  get formControlName() {
    return this.control.key;
  }
  get title() {
    return this.schema?.title ?? this.control.key;
  }
}
